
export interface DeviceServiceDetailParam {
    device_id: string;
}

export interface DeviceServiceDetailResult {
    id: string;
    name: string;
    uid: string;
    local_key: string;
    category: string;
    product_id: string;
    product_name: string;
    sub: boolean;
    uuid: string;
    asset_id: string;
    online: boolean;
    active_time: number;
    icon: string;
    ip: string;
    category_name: string
}

export interface HOME {
    "lon": number,
    "name": string,
    "home_id": number,
    "lat": number
    "geo_name": string
}

export interface DeviceServiceListParam {
    device_ids?: string[];
}

export interface DeviceServiceListResult {
    total: number;
    has_more: boolean;
    devices: {
        id: string;
        uid: string;
        local_key: string;
        category: string;
        product_id: string;
        sub: boolean;
        uuid: string;
        asset_id: string;
        online: boolean;
        name: string;
        ip: string;
        time_zone: string;
        create_time: number;
        update_time: number;
        active_time: number;
    }[];
}

export interface DeviceServiceResetParam {
    device_id: string;
}

export interface DeviceServiceDeleteParam {
    device_id: string;
}

export interface DeviceServiceDeleteBatchParam {
    device_ids: string[];
}

export interface DeviceServiceSubDeviceParam {
    device_id: string;
}

export interface DeviceServiceSubDeviceResult {
    id: string;
    name: string;
    online: boolean;
    asset_id: string;
    category: string;
    produce_id: string;
    active_time: number;
    update_time: number;
}

export interface DeviceServiceChangeNameParam {
    device_id: string;
    name: string;
}

export interface DeviceServiceFreezeStateParam {
    device_id: string;
}
export interface DeviceServiceFreezeStateResult {
    state: 0 | 1;
}


export interface DeviceServiceChangeFreezeStateParam {
    device_id: string;
    state: 0 | 1;
}

export interface DeviceServiceAssetDevicesParam {
    asset_id: string;
}
export interface DeviceServiceAssetDevicesResult {
    id: string;
}


export interface DeviceFunctionServiceCategoriesParam {
    category: 'kg' | 'cz' | 'dj' | string;
}

export interface DeviceFunctionServiceCategoriesResult {
    category: string;
    functions: {
        code: string;
        type: string;
        values: string;
        name: string;
        desc: string;
    }[];
}

export interface DeviceFunctionServiceDeviceParam {
    device_id: string;
}

export interface DeviceFunctionServiceDeviceResult {
    category: string;
    functions: {
        code: string;
        type: string;
        values: string;
        name: string;
        desc: string;
    }[];

}

export interface DeviceFunctionServiceSpecificationParam {
    device_id: string;
}

export interface SpecificationResultStatus {
    code: string;
    name: string;
    type: string;
    values: string;
}
export interface SpecificationResultFunction extends SpecificationResultStatus {
    desc: string;
}
export interface DeviceFunctionServiceSpecificationResult {
    category: string;
    functions: SpecificationResultFunction[];
    status: SpecificationResultStatus[];
}

export interface DeviceFunctionServiceCommandParam {
    device_id: string;
    commands: {
        code: string;
        value: string | boolean | number;
    }[];

}


export interface DeviceLogServiceLogParam {
    device_id: string;
    event_types: string;
    start_time: number;
    end_time: number;
    codes?: string;
    last_row_key?: string;
    size?: number;
    query_type?: 1 | 2;
}

export interface DeviceLogServiceLogResult {
    logs: {
        code: string;
        value: string;
        event_time: string;
        event_from: string;
        event_id: string;
    }[];
    has_next: boolean;
    device_id: string;
    last_row_key: string;
    count: number;
}

export interface DeviceLogServiceReportParam {
    device_id: string;
    start_time: number;
    end_time: number;
    codes: string[];
    last_row_key?: string;
    size?: number;
}

export interface DeviceLogServiceReportResult {
    device_id: string;
    has_more: boolean;
    last_row_key: string;
    total: number;
    logs: {
        code: string;
        value: string;
        event_time: number;
    }[];

}


export interface DeviceRegistrationTokenParam {
    pairing_type: 'ble' | 'ap' | 'ez';
    uid: string;
    time_zone_id: string;
    asset_id: string;
    extension?: {
        uuid: string; // ble 类型时需要传入
    };
}

export interface DeviceRegistrationTokenResult {
    expire_time: number;
    region: 'AY' | 'EU' | 'US';
    token: string;
    secret: string;
    extension: {
        encrypt_key: string;
        random: string;
    }
}

export interface DeviceRegistrationUseTokenParam {
    token: string;
}

export interface DeviceRegistrationUseTokenResult {
    success_devices: {
        device_id: string;
        product_id: string;
        name: string;
        category: string;
    }[];
    error_devices: {
        device_id: string;
        code: string;
        msg: string;
        name: string;
    }[];
}

export interface DeviceRegistrationDiscoverParam {
    device_id: string;
    duration: number; // 0-3600s, default 100s
}

export interface DeviceRegistrationStopDiscoverParam {
    device_id: string;
}


export interface DeviceRegistrationSubDeviceParam {
    device_id: string;
    discovery_time: number;
}
export interface DeviceRegistrationSubDeviceResult {
    id: string;
    name: string;
    asset_id: string;
    active_time: number;
    update_time: number;
    category: string;
    product_id: string;
    online: boolean;
}


export interface DeviceStatusServiceStatusParam {
    device_id: string;
}

export interface DeviceStatusServiceStatusResult {
    code: string;
    value: string;
}

export interface DeviceStatusServiceStatusListParam {
    device_ids: string[];
}

export interface DeviceStatusServiceStatusListResult {
    id: string;
    status: {
        code: string;
        value: any;
    }[];
}


export interface TuyaOpenApiAssetsGetParam {
    assetId: string;
}

export interface TuyaOpenApiAssetsGetResult {
    assetId: string;
    parent_asset_id: string;
    asset_name: string;
    asset_full_name: string;
}

export interface TuyaOpenApiAssetsListParam {
    assetId: string[];
}

export interface TuyaOpenApiAssetsListResult {
    assetId: string;
    parent_asset_id: string;
    asset_name: string;
    asset_full_name: string;
}

export interface TuyaOpenApiAssetsChildAssetsParam {
    asset_id: string;
    last_row_key?: string;
    page_size: number;
}

export interface TuyaOpenApiAssetsChildAssetsResult {
    list: {
        asset_id: string;
        parent_asset_id: string;
        asset_name: string;
        asset_full_name: string;
    }[];
    page_size: string;
    has_next: boolean;
    last_row_key: string;
}


export interface TuyaOpenApiAssetsDevicesParam {
    asset_id: string;
    last_row_key?: string;
    page_size: number;
}

export interface TuyaOpenApiAssetsDevicesResult {
    list: {
        device_id: string;
        asset_id: string;
        asset_name: string;
    }[];
    last_row_key: string;
    page_size: string;
    has_next: boolean;
}

export interface TuyaOpenApiAssetsAddParam {
    name: string;
    meta_id?: string;
    parent_asset_id?: string;
}

export interface TuyaOpenApiAssetsUpdateParam {
    asset_id: string;
    name: string;
    meta_id?: string;
}

export interface TuyaOpenApiAssetsDeleteParam {
    asset_id: string;
}


export interface TuyaOpenApiUserGetParam {
    user_id: string;
}

export interface TuyaOpenApiUserGetResult {
    user_id: string;
    user_name: string;
    country_code: string;
}

export interface TuyaOpenApiUserRegisterParam {
    username: string;
    password: string;
    country_code: string;
}

export interface TuyaOpenApiUserRegisterResult {
    user_id: string;
}

export interface TuyaOpenApiUserDeleteParam {
    user_id: string;
}


export interface TuyaOpenApiUserChangePasswordParam {
    user_id: string;
    old_password: string;
    new_password: string;
}

export interface TuyaOpenApiUserUsersParam {
    last_row_key?: string;
    page_size?: number;
}

export interface TuyaOpenApiUserUsersResult {
    list: {
        user_name: string;
        country_code: string;
        user_id: string;
    }[];
    last_row_key: string;
    page_size: number;
}

export interface TuyaGetListParam {
    source_type: 'asset' | 'homeApp' | 'tuyaUser' | 'product'
    source_id: string
    device_ids?: string
    name?: string
    category?: string
    product_id?: string
    last_row_key?: number
    page_size?: number
}



export type I = {
    name: string;
    category?: {
        name: string;
        code: string;
        dataname?: string
        disable?: boolean
        min?: number
        max?: number
        step?: number
        options?: { label: string, value: any }[]

    }[];
    rander: string;
}

export const switchs: I = {
    name: '开关',
    category: [
        {
            name: 'dj',
            code: 'switch_led',
        },
        {
            name: 'cjkg',
            code: 'switch_1',
            dataname: '开关一'
        },
        {
            name: 'cjkg',
            code: 'switch_2',
            dataname: '开关二'

        },
        {
            name: 'cjkg',
            code: 'switch_3',
            dataname: '开关三'

        },
        {
            name: 'cjkg',
            code: 'switch_4',
            dataname: '开关四'

        },
        {
            name: 'szjqr',
            code: 'switch',
        },
        {
            name: 'szjqr',
            code: 'tap_enable',
            dataname: '支持手动开关'
        },
        {
            name: 'sp',
            code: 'basic_flip',
            dataname: '反面翻转'
        },
        {
            name: 'sp',
            code: 'basic_osd',
            dataname: '时间水印'
        },
        {
            name: 'sp',
            code: 'basic_private',
            dataname: '隐私模式'
        },
        {
            name: 'sp',
            code: 'ptz_stop',
            dataname: '停止转动'
        },
        {
            name: 'sp',
            code: 'ipc_auto_siren',
            dataname: '联动蜂鸣器'
        },
        {
            name: 'sp',
            code: 'motion_switch',
            dataname: '移动报警开关'
        },
        {
            name: 'sp',
            code: 'floodlight_switch',
            dataname: '灯'
        },
        {
            name: 'sp',
            code: 'siren_switch',
            dataname: '警笛'
        },
        {
            name: 'mcs',
            code: 'doorcontact_state',
            dataname: '门磁状态',
            disable: true
        },
        {
            name: 'mcs',
            code: 'temper_alarm',
            dataname: '防拆报警',
            disable: true
        },
        {
            name: 'cz',
            code: 'switch_1',
            dataname: '开关',
        },
    ],

    rander: 'switch'
}

const delectoption: Record<string, string[]> = {
    dj: ['switch_led', 'work_mode', 'bright_value_v2', 'temp_value_v2', 'countdown_1', 'do_not_disturb']
}

export const slider: I = {
    name: '亮度',
    category: [
        {
            name: 'dj',
            code: 'bright_value_v2',
            dataname: '亮度',
            min: 10,
            max: 1000,
            step: 1,
        },
        {
            name: 'dj',
            code: 'temp_value_v2',
            dataname: '色温',
            min: 0,
            max: 1000,
            step: 1,
        },
        {
            name: 'dj',
            code: 'countdown_1',
            min: 0,
            max: 86400,
            step: 1,
            dataname: '倒计时',
        },
        {
            name: 'szjqr',
            code: 'arm_down_percent',
            dataname: '下降幅度',
            min: 0,
            max: 100,
            step: 1,
        },
        {
            name: 'szjqr',
            code: 'arm_up_percent',
            dataname: '上升幅度',
            min: 0,
            max: 50,
            step: 1,
        },
        {
            name: 'szjqr',
            code: 'click_sustain_time',
            dataname: '可回弹时间设置',
            min: 0,
            max: 10,
            step: 1,
        },
        {
            name: 'sp',
            code: 'ipc_siren_duration',
            dataname: '蜂鸣器时长',
            min: 10,
            max: 600,
            step: 10,
        },
        {
            name: 'cz',
            code: 'countdown_1',
            dataname: '开关倒计时',
            min: 0,
            max: 86400,
            step: 1,
        },
    ],
    rander: 'slider'
}




export const select: I = {
    name: '温标切换',
    category: [
        {
            name: 'wsdcg',
            code: 'temp_unit_convert',
            options: [
                {
                    label: '摄氏度',
                    value: 'c'
                },
                {
                    label: '华氏度',
                    value: 'f'
                }
            ],
            dataname: '温标切换'
        },
        {
            name: 'sp',
            code: 'ptz_control',
            options: [
                {
                    label: '1',
                    value: '1'
                },
                {
                    label: '2',
                    value: '2'
                },
                {
                    label: '3',
                    value: '3'
                },
                {
                    label: '4',
                    value: '4'
                },
                {
                    label: '5',
                    value: '5'
                },
                {
                    label: '6',
                    value: '6'
                },
                {
                    label: '7',
                    value: '7'
                },
                {
                    label: '0',
                    value: '0'
                },
            ],
            dataname: '云台转动'
        },
    ],
    rander: 'select',
}


export interface IwebrtcConfigs {
    "audio_attributes": {
        "call_mode": number[],
        "hardware_capability": number[]
    },
    "auth": string,
    "id": string,
    "moto_id": string,
    "p2p_config": {
        "auth": string,
        "ices":

        {
            "credential"?: string,
            "ttl"?: number,
            "urls"?: string,
            "username": string
        }[],
        "moto_id": string
    },
    "protocol_version": string,
    "skill": string,
    "support_webrtc_record": boolean,
    "supports_webrtc": boolean,
    "vedio_clarity": number,
    "vedio_claritys": number[]
}

export interface IwebrtcConfigsurl {
    "client_id": string,
    "expire_time": 7200,
    "password": string,
    "sink_topic": {
        "ipc": string
    },
    "source_topic": {
        "ipc": string
    },
    "url": string,
    "username": string
}

